Add workflow to auto-close linked playground items when PRs close#12439
Add workflow to auto-close linked playground items when PRs close#12439
Conversation
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
|
@radical input? |
| echo "PR number: $PR_NUMBER" | ||
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Download and install GitHub CLI |
There was a problem hiding this comment.
Why do we need to install this manually? The runners will have the cli installed.
| echo "Cleanup complete. Closed $CLOSED_COUNT item(s)." | ||
|
|
||
| - name: Comment on PR with cleanup summary | ||
| if: steps.cleanup.outputs.closed_count > 0 && github.event_name == 'issue_comment' |
There was a problem hiding this comment.
It might be useful to comment even when closed_count == 0, just so the user knows what happened.
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| PR_NUMBER="${{ steps.get_pr_number.outputs.pr_number }}" |
There was a problem hiding this comment.
| PR_NUMBER="${{ steps.get_pr_number.outputs.pr_number }}" | |
| set -euo pipefail # Exit on error, undefined vars, pipe failures | |
| PR_NUMBER="${{ steps.get_pr_number.outputs.pr_number }}" |
| runs-on: ubuntu-latest | ||
| env: | ||
| REPO_OWNER: dotnet | ||
| REPO_NAME: aspire-playground |
There was a problem hiding this comment.
Can we rename this to PLAYGROUND_REPO_NAME to avoid confusion when reading the code?
| QUERY='query($owner: String!, $repo: String!, $number: Int!) { | ||
| repository(owner: $owner, name: $repo) { | ||
| pullRequest(number: $number) { | ||
| closingIssuesReferences(first: 100) { |
There was a problem hiding this comment.
We don't seem to be using the results from matching the issues. Maybe jq could be used to extract the information from the result?
| # Find playground issue/PR references in format: https://github.com/dotnet/aspire-playground/issues/123 or /pull/123 | ||
| PLAYGROUND_REFS=$(echo -e "$PR_BODY\n$COMMENTS" | \ | ||
| grep -oP "https://github\.com/${REPO_OWNER}/${REPO_NAME}/(issues|pull)/\K\d+" | \ | ||
| sort -u) |
There was a problem hiding this comment.
We don't seem to be using the results from matching the issues with closingIssuesReferences. Maybe jq could be used to extract the information from the result?
Adds
test-scenario-cleanup.ymlworkflow to automatically clean up test scenario PRs/issues indotnet/aspire-playgroundwhen a PR closes in the main repository. Only closes items tagged withauto-closelabel.Triggers
/test-scenario-cleanupon a PRImplementation
auto-closelabel before closingGH_PLAYGROUND_TOKENsecret for playground authentication (same pattern astest-scenario.yml)Example
PR contains:
On PR close:
auto-close→ closes automaticallyauto-close→ skippedOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.